﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MusicPlayerPlus.PlugIn.MiniWindow
{
    /// <summary>
    /// TimeLine.xaml 的交互逻辑
    /// </summary>
    public partial class TimeLine : UserControl
    {
        public TimeLine()
        {
            InitializeComponent();
        }

        #region Attribute

        private double _max = 0;
        /// <summary>
        /// 最大值
        /// </summary>
        public double Max
        {
            get { return _max; }
            set
            {
                _max = value;
                this.ResetProgress();
            }
        }

        private double _val = 0;
        /// <summary>
        /// 当前的值
        /// </summary>
        public double Value
        {
            get { return _val; }
            set
            {
                _val = value;
                this.ResetProgress();
            }
        }

        /// <summary>
        /// Value 的百分比
        /// </summary>
        public double Percent
        {
            get
            {
                return Value / Max;
            }
        }


        #endregion

        #region Method
        /// <summary>
        /// 重新设置进度条长度
        /// </summary>
        private void ResetProgress()
        {
            double max = grid_timeline.ActualWidth;
            double w = this.Percent * max;
            re_timeline.Width = w;
        }
        private void grid_timeline_SizeChanged_1(object sender, SizeChangedEventArgs e)
        {
            this.ResetProgress();
        }

        #endregion
    }
}
